<?php
error_reporting(E_ALL);
$fname = filter_var($_POST["fname"]);
$sname = filter_var($_POST["sname"]);
$title = filter_var($_POST["title"]);
$type = filter_var($_POST["role"]);
$pnumber = filter_var($_POST["pnumber1"]);
$address = filter_var($_POST["address"]);
$contact_email = filter_var($_POST["contact_email"]);
$ice = filter_var($_POST["ice"]);
$user_email = filter_var($_POST["user_email"]);

$con=mysqli_connect("localhost","davidjwa_hack","hackathon16","davidjwa_hack");
// Check connection

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql = "INSERT INTO contacts (fname, sname, title, type, pnumber1, address, contact_email, ice, user_email)
VALUES ('$fname','$sname','$title','$type','$pnumber','$address','$contact_email','$ice','$user_email')";


if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo $fname . $sname ." added";

mysqli_close($con);

?>